Before we look at sample code, we need to clarify a few terms that the Drag Manager introduces: drag items, drag flavors, drag handlers, senders, and receivers.
The objects that a user drags are called drag items. For example, a user who selects and drags three files is dragging three different drag items.
Drag flavors describe the kind of data that a drag item contains. When a user drags an item to an application window, the receiving application must determine whether it can accept the data in the drag item. Each item can have more than one flavor, because data can usually be described in more than one format or data type. For example, you can describe text data as ASCII data, styled text data, or RTF interchange format; if a program can’t accept the more elaborate RTF format, it may be able to use the plain ASCII text. The Drag Manager uses a four-character ResType to identify a flavor.
The Drag Manager uses an application’s drag handlers to provide dragging feedback and to complete a drag. There are two types of drag handlers: tracking handlers and receive handlers. A tracking handler is called while an item is being dragged over an application’s windows; a receive handler is called when the user releases the mouse button to drop the item in a window. Each window has a tracking handler and receive handler installed for it, though several windows may use the same handler. When you initialize your application or open a new window, you call the Drag Manager to install your drag handler callback routines.
Because the Drag Manager provides interapplication drag and drop services, it’s important to know where the drag starts and where it ends. The application in which the drag starts is called the sender. Any application that the item is dragged over is a potential receiver of the drag; the application it’s dropped into is the actual receiver. The sender and receiver can be the same applications – but with interapplication dragging, another application could be the receiver of the drag.